package com.web.surf.sample.eshop.faces.managed.beans;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import com.web.surf.sample.eshop.dto.interfaces.IProperty;
import com.web.surf.sample.eshop.faces.core.AbstractBean;

/**
 * Goods substance 
 * @author LukyanyukDV
 * @author SavenkoNV
 */
@RequestScoped
@ManagedBean
public class GoodsBean extends AbstractBean {

	/**
	 * Goods properties 
	 * @author LukyanyukDV
	 * @author SavenkoNV
	 */
	public enum GoodsProperties implements IProperty {

		GOODS_ID("goods_id"),
		GOODS_SECTION("sub_id"),
		GOODS_PRODUCER("producer_name"),
		GOODS_MODEL("goods_model"),
		GOODS_PRICE("goods_price");

		private String databaseName;

		GoodsProperties(String databaseName) {
			this.setDatabaseName(databaseName);
		}

		public void setDatabaseName(String databaseName) {
			this.databaseName = databaseName;
		}

		public String getDatabaseName() {
			return databaseName;
		}
	}
	
	public boolean equals(Object o) {
		if ((o instanceof GoodsBean)&&(((GoodsBean)o).getGoodsID()
				==this.getGoodsID())) {
			return true;
		}
		else {
			return false;		
		}
	}
	
	public int hashCode() {
		return this.getGoodsID().hashCode();
	}

	// Getters of product properties
	public String getGoodsID() {
		return getProperty(GoodsProperties.GOODS_ID, String.class);
	}
	
	public SectionBean getGoodsSection() {
		return getProperty(GoodsProperties.GOODS_SECTION, SectionBean.class);
	}

	public String getModelValue() {
		return getProperty(GoodsProperties.GOODS_MODEL, String.class);
	}

	public String getProducerValue() {
		return getProperty(GoodsProperties.GOODS_PRODUCER, String.class);
	}

	public Double getPriceBYRValue() {
		return getProperty(GoodsProperties.GOODS_PRICE, Double.class);
	}

	// Setters of product properties
	public void setGoodsID(String value) {
		addProperty(GoodsProperties.GOODS_ID, value);
	}

	public void setGoodsSection(SectionBean section) {
		addProperty(GoodsProperties.GOODS_SECTION, section);
	}
	
	public void setProducerValue(String producerValue) {
		addProperty(GoodsProperties.GOODS_PRODUCER, producerValue);
	}

	public void setModelValue(String modelValue) {
		addProperty(GoodsProperties.GOODS_MODEL, modelValue);
	}

	public void setPriceBYRValue(Double priceBYRValue) {
		addProperty(GoodsProperties.GOODS_PRICE, priceBYRValue);
	}

}